package designPattern.composite;

import java.util.ArrayList;
import java.util.List;

//College 就是Composity ,可以管理 Department
public class College extends OrganizationCompoment{

    //聚合Department
    List<OrganizationCompoment> organizationCompoments = new ArrayList<>();

    public College(String name, String des){
        super(name,des);
    }

    //print输出Univerity包含的院校
    @Override
    protected void print() {
        System.out.println("--------------"+getName()+"------------------------");
        for (OrganizationCompoment organizationCompoment : organizationCompoments) {
            System.out.println(organizationCompoment.getName());
        }
    }

    //在这里直接复制了University的内容，在实际业务中，说不定会完全重写
    @Override
    protected void add(OrganizationCompoment organizationCompoment) {
        organizationCompoments.add(organizationCompoment);
    }

    @Override
    protected void remove(OrganizationCompoment organizationCompoment) {
        organizationCompoments.remove(organizationCompoment);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }
}
